const express=require('express');
const MemberInfo=require("../models/meberlnfo");
const router=new express.Router();
router.post('/Memberecharge',async(req,res)=>{
    console.log(req.body);
    const member=req.body
    const member_id=member.member_id;
    //余额的叠加
    const memberjiu=await MemberInfo.findOne({member_id},{
        __v:0,
        _id:0
    });
    member.remaining_sum=member.money * 1 + memberjiu.remaining_sum * 1;
    remaining_sum=member.remaining_sum;
    member_level=member. member_level;
    money = member.money;
    discount=member.discount
    console.log(member)

    const result=await MemberInfo.update({member_id},{$set:{remaining_sum,member_level,money,discount}})
    console.log(result);
    res.send('充值成功')
})



module.exports=router